home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxiparam.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.7 KB  |  260 lines

  1. /* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxiparam.h,v 1.2 2000/09/19 19:00:38 lpd Exp $ */
  20. /* Definitions for implementors of image types */
  21.  
  22. #ifndef gxiparam_INCLUDED
  23. #  define gxiparam_INCLUDED
  24.  
  25. #include "gsstype.h"        /* for extern_st */
  26. #include "gxdevcli.h"
  27.  
  28. /* ---------------- Image types ---------------- */
  29.  
  30. /* Define the structure for image types. */
  31.  
  32. #ifndef stream_DEFINED
  33. #  define stream_DEFINED
  34. typedef struct stream_s stream;
  35. #endif
  36.  
  37. #ifndef gx_image_type_DEFINED
  38. #  define gx_image_type_DEFINED
  39. typedef struct gx_image_type_s gx_image_type_t;
  40. #endif
  41.  
  42. struct gx_image_type_s {
  43.  
  44.     /*
  45.      * Define the storage type for this type of image.
  46.      */
  47.     gs_memory_type_ptr_t stype;
  48.  
  49.     /*
  50.      * Provide the default implementation of begin_typed_image for this
  51.      * type.
  52.      */
  53.     dev_proc_begin_typed_image((*begin_typed_image));
  54.  
  55.     /*
  56.      * Compute the width and height of the source data.  For images with
  57.      * explicit data, this information is in the gs_data_image_t
  58.      * structure, but ImageType 2 images must compute it.
  59.      */
  60. #define image_proc_source_size(proc)\
  61.   int proc(P3(const gs_imager_state *pis, const gs_image_common_t *pic,\
  62.     gs_int_point *psize))
  63.  
  64.     image_proc_source_size((*source_size));
  65.  
  66.     /*
  67.      * Put image parameters on a stream.  Currently this is used
  68.      * only for banding.  If the parameters include a color space,
  69.      * store it in *ppcs.
  70.      */
  71. #define image_proc_sput(proc)\
  72.   int proc(P3(const gs_image_common_t *pic, stream *s,\
  73.           const gs_color_space **ppcs))
  74.  
  75.     image_proc_sput((*sput));
  76.  
  77.     /*
  78.      * Get image parameters from a stream.  Currently this is used
  79.      * only for banding.  If the parameters include a color space,
  80.      * use pcs.
  81.      */
  82. #define image_proc_sget(proc)\
  83.   int proc(P3(gs_image_common_t *pic, stream *s, const gs_color_space *pcs))
  84.  
  85.     image_proc_sget((*sget));
  86.  
  87.     /*
  88.      * Release any parameters allocated by sget.
  89.      * Currently this only frees the parameter structure itself.
  90.      */
  91. #define image_proc_release(proc)\
  92.   void proc(P2(gs_image_common_t *pic, gs_memory_t *mem))
  93.  
  94.     image_proc_release((*release));
  95.  
  96.     /*
  97.      * We put index last so that if we add more procedures and some
  98.      * implementor fails to initialize them, we'll get a type error.
  99.      */
  100.     int index;        /* PostScript ImageType */
  101. };
  102.  
  103. /*
  104.  * Define the procedure for getting the source size of an image with
  105.  * explicit data.
  106.  */
  107. image_proc_source_size(gx_data_image_source_size);
  108. /*
  109.  * Define dummy sput/sget/release procedures for image types that don't
  110.  * implement these functions.
  111.  */
  112. image_proc_sput(gx_image_no_sput); /* rangecheck error */
  113. image_proc_sget(gx_image_no_sget); /* rangecheck error */
  114. image_proc_release(gx_image_default_release); /* just free the params */
  115. /*
  116.  * Define sput/sget/release procedures for generic pixel images.
  117.  * Note that these procedures take different parameters.
  118.  */
  119. int gx_pixel_image_sput(P4(const gs_pixel_image_t *pic, stream *s,
  120.                const gs_color_space **ppcs, int extra));
  121. int gx_pixel_image_sget(P3(gs_pixel_image_t *pic, stream *s,
  122.                const gs_color_space *pcs));
  123. void gx_pixel_image_release(P2(gs_pixel_image_t *pic, gs_memory_t *mem));
  124.  
  125. /* Internal procedures for use in sput/sget implementations. */
  126. bool gx_image_matrix_is_default(P1(const gs_data_image_t *pid));
  127. void gx_image_matrix_set_default(P1(gs_data_image_t *pid));
  128. void sput_variable_uint(P2(stream *s, uint w));
  129. int sget_variable_uint(P2(stream *s, uint *pw));
  130. #define DECODE_DEFAULT(i, dd1)\
  131.   ((i) == 1 ? dd1 : (i) & 1)
  132.  
  133. /* ---------------- Image enumerators ---------------- */
  134.  
  135. #ifndef gx_image_enum_common_t_DEFINED
  136. #  define gx_image_enum_common_t_DEFINED
  137. typedef struct gx_image_enum_common_s gx_image_enum_common_t;
  138. #endif
  139.  
  140. /*
  141.  * Define the procedures associated with an image enumerator.
  142.  */
  143. typedef struct gx_image_enum_procs_s {
  144.  
  145.     /*
  146.      * Pass the next batch of data for processing.  *rows_used is set
  147.      * even in the case of an error.
  148.      */
  149.  
  150. #define image_enum_proc_plane_data(proc)\
  151.   int proc(P4(gx_image_enum_common_t *info, const gx_image_plane_t *planes,\
  152.           int height, int *rows_used))
  153.  
  154.     image_enum_proc_plane_data((*plane_data));
  155.  
  156.     /*
  157.      * End processing an image, freeing the enumerator.  We keep this
  158.      * procedure as the last required one, so that we can detect obsolete
  159.      * static initializers.
  160.      */
  161.  
  162. #define image_enum_proc_end_image(proc)\
  163.   int proc(P2(gx_image_enum_common_t *info, bool draw_last))
  164.  
  165.     image_enum_proc_end_image((*end_image));
  166.  
  167.     /*
  168.      * Flush any intermediate buffers to the target device.
  169.      * We need this for situations where two images interact
  170.      * (currently, only the mask and the data of ImageType 3).
  171.      *
  172.      * This procedure is optional (may be 0).
  173.      */
  174.  
  175. #define image_enum_proc_flush(proc)\
  176.   int proc(P1(gx_image_enum_common_t *info))
  177.  
  178.     image_enum_proc_flush((*flush));
  179.  
  180.     /*
  181.      * Determine which data planes should be passed on the next call to the
  182.      * plane_data procedure, by filling wanted[0 .. num_planes - 1] with 0
  183.      * for unwanted planes and non-0 for wanted planes.  This procedure may
  184.      * also change the plane_depths[] and/or plane_widths[] values.  The
  185.      * procedure returns true if the returned vector will always be the same
  186.      * *and* the plane depths and widths remain constant, false if the
  187.      * wanted planes *or* plane depths or widths may vary over the course of
  188.      * the image.  Note also that the only time a plane's status can change
  189.      * from wanted to not wanted, and the only time a wanted plane's depth
  190.      * or width can change, is after a call of plane_data that actually
  191.      * provides data for that plane.
  192.      *
  193.      * By default, all data planes are always wanted; however, ImageType 3
  194.      * images with separate mask and image data sources may want mask data
  195.      * before image data or vice versa.
  196.      * 
  197.      * This procedure is optional (may be 0).
  198.      */
  199.  
  200. #define image_enum_proc_planes_wanted(proc)\
  201.   bool proc(P2(const gx_image_enum_common_t *info, byte *wanted))
  202.  
  203.     image_enum_proc_planes_wanted((*planes_wanted));
  204.  
  205. } gx_image_enum_procs_t;
  206.  
  207. /*
  208.  * Define the common prefix of the image enumerator structure.  All
  209.  * implementations of begin[_typed]_image must initialize all of the members
  210.  * of this structure, by calling gx_image_enum_common_init and then filling
  211.  * in whatever else they need to.
  212.  *
  213.  * Note that the structure includes a unique ID, so that the banding
  214.  * machinery could in principle keep track of multiple enumerations that may
  215.  * be in progress simultaneously.
  216.  */
  217. #define gx_image_enum_common\
  218.     const gx_image_type_t *image_type;\
  219.     const gx_image_enum_procs_t *procs;\
  220.     gx_device *dev;\
  221.     gs_id id;\
  222.     int num_planes;\
  223.     int plane_depths[gs_image_max_planes];    /* [num_planes] */\
  224.     int plane_widths[gs_image_max_planes]    /* [num_planes] */
  225. struct gx_image_enum_common_s {
  226.     gx_image_enum_common;
  227. };
  228.  
  229. extern_st(st_gx_image_enum_common);
  230. #define public_st_gx_image_enum_common()    /* in gdevddrw.c */\
  231.   gs_public_st_composite(st_gx_image_enum_common, gx_image_enum_common_t,\
  232.     "gx_image_enum_common_t",\
  233.      image_enum_common_enum_ptrs, image_enum_common_reloc_ptrs)
  234.  
  235. /*
  236.  * Initialize the common part of an image enumerator.
  237.  */
  238. int gx_image_enum_common_init(P6(gx_image_enum_common_t * piec,
  239.                  const gs_data_image_t * pic,
  240.                  const gx_image_enum_procs_t * piep,
  241.                  gx_device * dev, int num_components,
  242.                  gs_image_format_t format));
  243.  
  244. /*
  245.  * Define image_plane_data and end_image procedures for image types that
  246.  * don't have any source data (ImageType 2 and composite images).
  247.  */
  248. image_enum_proc_plane_data(gx_no_plane_data);
  249. image_enum_proc_end_image(gx_ignore_end_image);
  250. /*
  251.  * Define the procedures and type data for ImageType 1 images,
  252.  * which are always included and which are shared with ImageType 4.
  253.  */
  254. dev_proc_begin_typed_image(gx_begin_image1);
  255. image_enum_proc_plane_data(gx_image1_plane_data);
  256. image_enum_proc_end_image(gx_image1_end_image);
  257. image_enum_proc_flush(gx_image1_flush);
  258.  
  259. #endif /* gxiparam_INCLUDED */
  260.